package org.tacademy.and12.mesapp;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MyAdapterWIP extends ArrayAdapter<MyDataWIP> {

	ArrayList<MyDataWIP> mList;
	Context mContext;
	TextView lot;
	TextView qty;
	TextView process;
	TextView workDate;
	
	public MyAdapterWIP(Context context, ArrayList<MyDataWIP> list) {
		super(context, 0, list);
		// TODO Auto-generated constructor stub
		mList = list;
		mContext = context;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		LinearLayout layoutMyData;
		
		if(convertView == null){
			LayoutInflater inflater = LayoutInflater.from(mContext);
			layoutMyData = (LinearLayout)inflater.inflate(R.layout.fragment_view_wip_sublayout, null);
		}else{
			layoutMyData = (LinearLayout)convertView;
		}
		
		lot = (TextView)layoutMyData.findViewById(R.id.txtLot);
		qty = (TextView)layoutMyData.findViewById(R.id.txtQty);
		process = (TextView)layoutMyData.findViewById(R.id.txtProcess);
		workDate = (TextView)layoutMyData.findViewById(R.id.txtWorkDate);
		
		MyDataWIP currentData = mList.get(position);
		
		lot.setText(currentData.lot);
		qty.setText(currentData.quantity+"");
		process.setText(currentData.process);
		workDate.setText(currentData.workdate);		
			
		return (View)layoutMyData;
	}

}
